/*
 * NetRayt
 * Copyright (c) 2007-2008 Maciej Nabozny.
 *
 * NetRayt is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * NetRayt is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with NetRayt; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/

#include "client.h"

#include "conn_class/conn.h"

client::client(QWidget *parent, Qt::WFlags f): QMainWindow(parent, f) {
	ui.setupUi(this);
	
	// Połącz sloty
	connect(ui.exitButton, SIGNAL(clicked()), this, SLOT(endApp()));
	connect(ui.addServer, SIGNAL(clicked()), this, SLOT(addSrv()));
	connect(ui.delServer, SIGNAL(clicked()), this, SLOT(removeSrv()));
	connect(ui.selectFile, SIGNAL(clicked()), this, SLOT(selectFile()));
	connect(ui.tabWidget, SIGNAL(currentChanged(int)), this, SLOT(updateServers(int)));
	connect(ui.startRender, SIGNAL(clicked()), this, SLOT(startRender()));
	
	// Stwórz model tabelki
	servers = new QStandardItemModel(8, 0);
	
	servers->setHeaderData(0, Qt::Vertical, tr("Host:"));
	servers->setHeaderData(1, Qt::Vertical, tr("Port:"));
	servers->setHeaderData(2, Qt::Vertical, tr("Cpu freq:"));
	servers->setHeaderData(3, Qt::Vertical, tr("Cpu cnt:"));
	servers->setHeaderData(4, Qt::Vertical, tr("Memory:"));
	servers->setHeaderData(5, Qt::Vertical, tr("Yafray:"));
	servers->setHeaderData(6, Qt::Vertical, tr("Blender:"));
	servers->setHeaderData(7, Qt::Vertical, tr("Indigo:"));
	
	ui.serverListTable->setSelectionBehavior(QAbstractItemView::SelectColumns);
	
	// Ustaw model tabelki
	ui.serverListTable->setModel(servers);
	
	serverThreadList = NULL;
}

/******************************************************************************/
/*                       Obsługa zakładki z opcjami raytracera                */
/******************************************************************************/

/*
 * Wybór pliku
 */
void client::selectFile() {
	scene = QFileDialog::getOpenFileName(this, tr("Wybierz plik ze sceną"));
	ui.filename->setText(scene);
}
